﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ThoiTrang.Business;
using ThoiTrang.Entities;

public partial class user_fav_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!SessionManager.IsLogged)
            Response.Redirect("login.aspx?ckid=" + SessionManager.GetCookie(), true);        
        //dt = 1: muc yeu thich
        //dt = 2: bai yeu thich
        if (!SessionManager.IsLogged)
        {
            Response.Redirect("login.aspx?ckid=" + SessionManager.GetCookie(), true);
        }
        else
        {
            a_Favorite fav = new a_Favorite();
            fav.DateAdded = DateTime.Now;
            fav.AlbumID = 0;
            fav.FavoriteType = byte.Parse(Request["dt"]);
            fav.FavoriteID = int.Parse( Request["fid"]);
            a_FavoriteService.Createa_FavoriteBySSID(fav, SessionManager.GetCookie());
            switch (Request["dt"])
            {
                case "1":
                    Response.Redirect("listing.aspx?a=add&dt=1&fid=" + Request["fid"] + "&mcid=" + Request["mcid"] + "&scid=" + Request["fid"] + "&ckid=" + SessionManager.GetCookie() + "&msg=1", true);
                    break;
                case "2":
                    Response.Redirect("detail.aspx?aid=" + Request["fid"] + "&ckid=" + SessionManager.GetCookie() + "&msg=1", true);
                    break;
                default:
                    Response.Redirect("index.aspx?ckid=" + SessionManager.GetCookie(), true);
                    break;
            }
            
        }
    }
}
